package com.cicigodd.brick.plug.common.response;

/**
 * 响应结果生成工具
 *
 * @author cicigodd
 * @date 2022/09/23 08:42:00
 */
public class ResultGenerator {

    public static Result successResult() {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(ResultCode.SUCCESSMSG);
    }

    public static <T> Result<T> successResult(T data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(ResultCode.SUCCESSMSG)
                .setData(data);
    }

    public static <T> Result<T> successResult(String message, T data) {
        return new Result()
                .setCode(ResultCode.SUCCESS)
                .setMessage(message)
                .setData(data);
    }

    public static Result failResult() {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setSuccess(false)
                .setMessage(ResultCode.FAILMSG);
    }

    public static Result failResult(String message) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message)
                .setSuccess(false);
    }

    public static <T> Result<T> failResult(String message, T data) {
        return new Result()
                .setCode(ResultCode.FAIL)
                .setMessage(message)
                .setData(data)
                .setSuccess(false);
    }

    public static Result failResult(Integer code, String message) {
        return new Result()
                .setCode(code)
                .setMessage(message)
                .setSuccess(false);
    }

    public static Result unauthorizedResult() {
        return new Result()
                .setCode(ResultCode.UNAUTHORIZED)
                .setSuccess(false)
                .setMessage(ResultCode.UNAUTHORIZEDMSG);
    }

    public static Result tokenFailResult() {
        return new Result()
                .setCode(ResultCode.TOKENFAIL)
                .setSuccess(false)
                .setMessage(ResultCode.TOKENFAILMSG);
    }

    public static Result tokenFailResult(String message) {
        return new Result()
                .setCode(ResultCode.TOKENFAIL)
                .setSuccess(false)
                .setMessage(message);
    }

    public static Result foundFailResult() {
        return new Result()
                .setCode(ResultCode.NOT_FOUND)
                .setSuccess(false)
                .setMessage(ResultCode.NOT_FOUNDMSG);
    }

    public static Result foundFailResult(String message) {
        return new Result()
                .setCode(ResultCode.NOT_FOUND)
                .setSuccess(false)
                .setMessage(message);
    }

    public static Result serverFailResult() {
        return new Result()
                .setCode(ResultCode.INTERNAL_SERVER_ERROR)
                .setSuccess(false)
                .setMessage(ResultCode.INTERNAL_SERVER_ERRORMSG);
    }

    public static Result serverFailResult(String message) {
        return new Result()
                .setCode(ResultCode.INTERNAL_SERVER_ERROR)
                .setSuccess(false)
                .setMessage(message);
    }

}
